<!DOCTYPE html>
<html>
<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
	<style type="text/css">
		@import url(./../lib/Cesium/Widgets/widgets.css);

		body,
		html,
		#map {
			width: 100%;
			height: 100%;
			overflow: hidden;
			margin: 0;
			font-family: "微软雅黑";
		}
	</style>

	<script src="./../lib/lodash.min.js"></script>
	<script src="./../lib/Cesium/Cesium.js"></script>
	<title>水面特效</title>
</head>

<body onload="onload()">
	<div id="map"></div>
</body>

</html>
<script type="text/javascript">
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI5NTFhMDMwMi02YWVjLTRmNmItOThjNS00MDI1YTVkNjdhODciLCJpZCI6NTY0Miwic2NvcGVzIjpbImFzciIsImdjIl0sImlhdCI6MTU0MzgyNzA5MH0.4OIh4gPgWSceyKB4iHliAX59933ryNrXBwVut46WE78'
	function onload() {
		const viewer = new Cesium.Viewer("map", {
			animation: false, //是否创建动画小器件，左下角仪表
			baseLayerPicker: false, //是否显示图层选择器
			fullscreenButton: false, //是否显示全屏按钮
			geocoder: false, //是否显示geocoder小器件，右上角查询按钮
			homeButton: false, //是否显示Home按钮
			infoBox: false, //是否显示信息框
			sceneModePicker: false, //是否显示3D/2D选择器
			selectionIndicator: false, //是否显示选取指示器组件
			timeline: false, //是否显示时间轴
			sceneMode: Cesium.SceneMode.SCENE3D, //设定3维地图的默认场景模式:Cesium.SceneMode.SCENE2D、Cesium.SceneMode.SCENE3D、Cesium.SceneMode.MORPHING
			navigationHelpButton: false, //是否显示右上角的帮助按钮
			scene3DOnly: true, //如果设置为true，则所有几何图形以3D模式绘制以节约GPU资源
			navigationInstructionsInitiallyVisible: false,
			showRenderLoopErrors: false

		})
		viewer.scene.globe.depthTestAgainstTerrain = false;
		//去除版权信息
		viewer._cesiumWidget._creditContainer.style.display = 'none';


		viewer.camera.setView({
			destination: Cesium.Cartesian3.fromDegrees(104.02820259332657,
				30.660133455045184, 1500.0), // 设置位置
			orientation: {
				heading: Cesium.Math.toRadians(20.0), // 方向
				pitch: Cesium.Math.toRadians(-90.0),// 倾斜角度
				roll: 0
			}
		});



		let points = [
			[
				104.02960002422333,
				30.660304191821805
			],
			[
				104.02951955795288,
				30.660304191821805
			],
			[
				104.0294498205185,
				30.66032264983363
			],
			[
				104.02939081192017,
				30.660350336844797
			],
			[
				104.02934253215788,
				30.660391867346647
			],
			[
				104.02931034564972,
				30.660461084810066
			],
			[
				104.02927815914154,
				30.660553374684174
			],
			[
				104.02924060821532,
				30.660631821007904
			],
			[
				104.02917623519897,
				30.66067335138879
			],
			[
				104.02908504009247,
				30.66075179761512
			],
			[
				104.02896702289581,
				30.660811785862876
			],
			[
				104.02884900569916,
				30.660830243777788
			],
			[
				104.02872025966644,
				30.660834858255956
			],
			[
				104.0285861492157,
				30.66083947273392
			],
			[
				104.02846813201904,
				30.660844087211654
			],
			[
				104.02836084365845,
				30.660830243777788
			],
			[
				104.02830183506012,
				30.660793327944457
			],
			[
				104.02823209762572,
				30.66077487002252
			],
			[
				104.02817308902739,
				30.660742568650615
			],
			[
				104.02811408042906,
				30.660728725202222
			],
			[
				104.02794778347015,
				30.660710267267948
			],
			[
				104.0278673171997,
				30.660677965874466
			],
			[
				104.02772784233093,
				30.660650278957167
			],
			[
				104.02756154537201,
				30.660636435495537
			],
			[
				104.02749717235565,
				30.66061336305511
			],
			[
				104.0274167060852,
				30.66057644713893
			],
			[
				104.02738451957703,
				30.660530302223926
			],
			[
				104.02736842632292,
				30.660479542791947
			],
			[
				104.02735769748688,
				30.660410325341733
			],
			[
				104.02735233306885,
				30.660308806325087
			],
			[
				104.02735233306885,
				30.66023958875261
			],
			[
				104.02734160423279,
				30.660198058185316
			],
			[
				104.02732014656067,
				30.66014268406785
			],
			[
				104.02727723121643,
				30.660091924432294
			],
			[
				104.0272182226181,
				30.660041164770096
			],
			[
				104.02716994285583,
				30.65999963411754
			],
			[
				104.02711629867554,
				30.659939645365704
			],
			[
				104.02708411216734,
				30.659884271100175
			],
			[
				104.02705729007721,
				30.659796595114866
			],
			[
				104.02705192565918,
				30.659764293416025
			],
			[
				104.02704656124115,
				30.659699689985953
			],
			[
				104.02704119682312,
				30.659607399296657
			],
			[
				104.02702510356902,
				30.659501264895027
			],
			[
				104.02702510356902,
				30.659459734010497
			],
			[
				104.02727723121643,
				30.65946896309749
			],
			[
				104.02741134166718,
				30.659464348554106
			],
			[
				104.02749717235565,
				30.659427432199063
			],
			[
				104.02759909629822,
				30.659408974016248
			],
			[
				104.02767956256866,
				30.659348984897807
			],
			[
				104.02775466442108,
				30.65929822484542
			],
			[
				104.02781367301941,
				30.6592520793201
			],
			[
				104.02785658836365,
				30.6592290065492
			],
			[
				104.02795314788818,
				30.659192090104288
			],
			[
				104.02807652950287,
				30.659178246433786
			],
			[
				104.02815699577332,
				30.659173631876513
			],
			[
				104.0282267332077,
				30.659173631876513
			],
			[
				104.02836620807648,
				30.659141329969483
			],
			[
				104.02849495410918,
				30.659159788203418
			],
			[
				104.02865052223206,
				30.65920593377278
			],
			[
				104.02876853942871,
				30.6592520793201
			],
			[
				104.02891874313353,
				30.65929361029387
			],
			[
				104.02902066707611,
				30.659321297599806
			],
			[
				104.02911186218262,
				30.659330526700032
			],
			[
				104.02917623519897,
				30.65936282854383
			],
			[
				104.02920305728912,
				30.6594320467442
			],
			[
				104.02920305728912,
				30.659524337600946
			],
			[
				104.02917623519897,
				30.65958432661056
			],
			[
				104.02917623519897,
				30.659653544652333
			],
			[
				104.02926206588744,
				30.659741220767383
			],
			[
				104.02936398983002,
				30.65981505322364
			],
			[
				104.02945518493652,
				30.659902729192204
			],
			[
				104.02949810028076,
				30.659944259886387
			],
			[
				104.02955710887909,
				30.660073466376396
			],
			[
				104.0295946598053,
				30.66015652760019
			],
			[
				104.02962684631348,
				30.66020267269369
			],
			[
				104.02960002422333,
				30.660304191821805
			]
		]
		points = _.flattenDeep(points);

		function waterMaterial(primitive) {
			primitive.appearance.material = new Cesium.Material({
				fabric: {
					type: "Water",
					uniforms: {
						normalMap: './../img/cesium/c1_3.jpg',
						frequency: 1000.0,
						animationSpeed: 0.01,
						amplitude: 1.0 
					}
				}
			})
		}
		//创建primitive 对象
		var clhPrimitive = viewer.scene.primitives.add(new Cesium.Primitive({
			geometryInstances: new Cesium.GeometryInstance({
				geometry: new Cesium.PolygonGeometry({
					polygonHierarchy: new Cesium.PolygonHierarchy(Cesium.Cartesian3.fromDegreesArray(points)),
					vertexFormat: Cesium.EllipsoidSurfaceAppearance.VERTEX_FORMAT 
				})
			}),
			appearance: new Cesium.EllipsoidSurfaceAppearance({
				aboveGround: true
			}),
			show: true
		}));

		waterMaterial(clhPrimitive);
		viewer.flyTo(clhPrimitive)

	}

</script>